package GameLogic
{
	import DataStore.BmpDataPool;
	import fl.controls.CheckBox;
	import fl.controls.Slider;
	import flash.display.Bitmap;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import flash.ui.Mouse;
	import flash.ui.MouseCursor;
	import RobotPlayer.BaseRobot;
	import RobotPlayer.RobotFactory;
	public class SetPanel extends Sprite
	{
		public var radar:CheckBox;
		public var radarline:CheckBox;
		public var assistLine:CheckBox;
		public var topCoor:CheckBox;
		public var bottomCoor:CheckBox;
		public var turnoffSound:CheckBox;
		
		public var MassSlider:Slider;
		public var SpeedSlider:Slider;
		public var ForceSlider:Slider;

		private var  w:int;
		private var h:int;
		public function SetPanel()
		{
			var shape:Shape = new Shape();
			var shape2:Shape =  new Shape();
			var shape3:Shape = new Shape();
			shape3.graphics.beginFill(0x063722, 0.9);
			shape3.graphics.drawRect(110, 20, 100, 20);
			shape2.graphics.lineStyle(1, 0xffffff);
			shape2.graphics.drawRect(10, 20, 280, 360);
			shape.graphics.beginFill(0x063722, 0.95);
			shape.graphics.drawRoundRect(0, 0, 300, 390, 5, 5);
			this.addChild(shape);
			this.addChild(shape2);
			var img:Bitmap = new Bitmap(BmpDataPool.LuaeditPool[4052]);
			img.width = 300;
			img.height = 390;
			img.alpha = 0.05;
			this.addChild(img);
			this.addChild(shape3);
			var img2:Bitmap = new Bitmap(BmpDataPool.LuaeditPool[4024]);
			img2.x = 112;
			img2.y = 0;
			img2.alpha = 0.9;
			this.addChild(img2);
			var st:TextField = new TextField();
			st.text = "设  置";
			st.selectable = false;
			st.textColor = 0xccff99;
			addChild(st);
			st.x = 165;
			st.y = 10;
			st.scaleX = 1.2;
			st.scaleY = 1.2;
			
			var startX:int = 36;
			
			radar = new CheckBox();
			radar.label = "";
			var radarTxt:TextField =  new TextField();
			radarTxt.text = "显示雷达";
			radarTxt.textColor = 0xffffff;
			this.addChild(radarTxt);
			this.addChild(radar);
			radar.x = startX;
			radar.y = 45;
			radarTxt.x = radar.x + 30;
			radarTxt.y = radar.y;
			radarTxt.selectable = false;
			radar.selected = true;
			radar.addEventListener(MouseEvent.MOUSE_OVER, function(e:Event):void
			{
				Game.AddTooltip(Game.SetButton.SettingPanel, radar, " : 界面左上角的全局雷达，显示所有机器人的相对位置", 87, 0);
			});
			radar.addEventListener(MouseEvent.MOUSE_OUT, function(e:Event):void
			{
				Game.RemoveTooltip();
			});
			
			radarline = new CheckBox();
			radarline.label = "";
			var radarlineTxt:TextField =  new TextField();
			radarlineTxt.text = "显示雷达扫描线";
			radarlineTxt.textColor = 0xffffff;
			this.addChild(radarlineTxt);
			this.addChild(radarline);
			radarline.x = startX;
			radarline.y = 70;
			radarlineTxt.x = radarline.x + 30;
			radarlineTxt.y = radarline.y;
			radarlineTxt.selectable = false;
			radarline.selected = true;
			radarline.addEventListener(MouseEvent.MOUSE_OVER, function(e:Event):void
			{
				Game.AddTooltip(Game.SetButton.SettingPanel, radarline, " : 机器人的雷达扫描线,必须被雷达扫描到的物体才能被机器人感知", 117, 0);
			});
			radarline.addEventListener(MouseEvent.MOUSE_OUT, function(e:Event):void
			{
				Game.RemoveTooltip();
			});
			
			assistLine = new CheckBox();
			assistLine.label = "";
			var assistLineTxt:TextField =  new TextField();
			assistLineTxt.text = "显示碰撞框";
			assistLineTxt.textColor = 0xffffff;
			this.addChild(assistLineTxt);
			this.addChild(assistLine);
			assistLine.x = startX;
			assistLine.y = 95;
			assistLineTxt.x = assistLine.x + 30;
			assistLineTxt.y = assistLine.y;
			assistLineTxt.selectable = false;
			assistLine.addEventListener(MouseEvent.MOUSE_OVER, function(e:Event):void
			{
				Game.AddTooltip(Game.SetButton.SettingPanel, assistLine, " : 显示一个红色圆圈,这是机器人的碰撞范围", 105, 0);
			});
			assistLine.addEventListener(MouseEvent.MOUSE_OUT, function(e:Event):void
			{
				Game.RemoveTooltip();
			});
			
			topCoor = new CheckBox();
			topCoor.label = "";
			var topCoorTxt:TextField =  new TextField();
			topCoorTxt.width = 200;
			topCoorTxt.text = "显示指令舱局部坐标";
			topCoorTxt.textColor = 0xffffff;
			this.addChild(topCoorTxt);
			this.addChild(topCoor);
			topCoor.x = startX;
			topCoor.y = 120;
			topCoorTxt.x = topCoor.x + 30;
			topCoorTxt.y = topCoor.y;
			topCoorTxt.selectable = false;
			topCoor.addEventListener(MouseEvent.MOUSE_OVER, function(e:Event):void
			{
				Game.AddTooltip(Game.SetButton.SettingPanel, topCoor, " : 指令舱(类似炮塔)的局部坐标系,绿色Y坐标,红色X坐标", 145, 0);
			});
			topCoor.addEventListener(MouseEvent.MOUSE_OUT, function(e:Event):void
			{
				Game.RemoveTooltip();
			});
			
			bottomCoor = new CheckBox();
			bottomCoor.label = "";
			var bottomCoorTxt:TextField =  new TextField();
			bottomCoorTxt.width = 150;
			bottomCoorTxt.text = "显示行动机构局部坐标";
			bottomCoorTxt.textColor = 0xffffff;
			this.addChild(bottomCoorTxt);
			this.addChild(bottomCoor);
			bottomCoor.x = startX;
			bottomCoor.y = 145;
			bottomCoorTxt.x = bottomCoor.x + 30;
			bottomCoorTxt.y = bottomCoor.y;
			bottomCoorTxt.selectable = false;
			bottomCoor.addEventListener(MouseEvent.MOUSE_OVER, function(e:Event):void
			{
				Game.AddTooltip(Game.SetButton.SettingPanel, bottomCoor, " : 行动机构(类似底盘)的局部坐标系,绿色Y坐标,红色X坐标", 165, 0);
			});
			bottomCoor.addEventListener(MouseEvent.MOUSE_OUT, function(e:Event):void
			{
				Game.RemoveTooltip();
			});
			
			turnoffSound = new CheckBox();
			turnoffSound.label = "";
			var turnoffSoundTxt:TextField =  new TextField();
			turnoffSoundTxt.width = 150;
			turnoffSoundTxt.text = "开启音效";
			turnoffSoundTxt.textColor = 0xffffff;
			this.addChild(turnoffSoundTxt);
			this.addChild(turnoffSound);
			turnoffSound.x = startX;
			turnoffSound.y = 170;
			turnoffSoundTxt.x = turnoffSound.x + 30;
			turnoffSoundTxt.y = turnoffSound.y;
			turnoffSoundTxt.selectable = false;
			turnoffSound.addEventListener(MouseEvent.MOUSE_OVER, function(e:Event):void
			{
				Game.AddTooltip(Game.SetButton.SettingPanel, turnoffSound, " : 开启音效", 165, 0);
			});
			turnoffSound.addEventListener(MouseEvent.MOUSE_OUT, function(e:Event):void
			{
				Game.RemoveTooltip();
			});
			turnoffSound.selected = true;
			
			var copy:TextField = new TextField();
			copy.wordWrap = true;
			copy.selectable = false;
			copy.width = 239;
			var st1:String = "------------  ☞  机器人要素调节 -----------";
			copy.text = st1;
			copy.textColor = 0xBFF2E5;
			addChild(copy);
			copy.x = 52;
			copy.y = 190;
			
			var au:TextField = new TextField();
			au.wordWrap = true;
			au.selectable = false;
			au.width = 239;
			var st4:String = "------------ ☞  说明；  -----------";
			au.text = st4;
			au.textColor = 0xBFF2E5;
			this.addChild(au);
			au.x = 52;
			au.y = 300;
			
			var au1:TextField = new TextField();
			au1.wordWrap = true;
			au1.selectable = false;
			au1.width = 239;
			var st3:String = " 默认因子（5）不改变    +增大   -减小            机甲运动符合物理定律 ";
			au1.text = st3;
			au1.textColor = 0xE2ECE9;
			addChild(au1);
			au1.x = 35;
			au1.y = 330;
			
			var close:TextField = new TextField();
			close.selectable = false;
			close.background = true;
			close.backgroundColor = 0xE2ECE9;
			close.width = 40;
			close.height = 18;
			close.text = "  关 闭";
			close.textColor = 0x063722;
			close.border = true;
			close.borderColor = 0x000000;
			addChild(close);
			close.x = 245;
			close.y = 368;
			
			close.addEventListener(MouseEvent.CLICK, function(e:Event):void
			{
				Game.SetButton.Close();				
			});
			close.addEventListener(MouseEvent.MOUSE_OVER, function(e:Event):void
			{
				Mouse.cursor = MouseCursor.BUTTON;
			});
			close.addEventListener(MouseEvent.MOUSE_OUT, function(e:Event):void
			{
				Mouse.cursor = MouseCursor.AUTO;
			});
			
			var tP:int = 140;
			var vP:int = 250;
			var massTxt:TextField = new TextField();
			massTxt.text = "质 量   × ";
			massTxt.x = tP;
			massTxt.y = 212;
			massTxt.textColor = 0xffffff;
			addChild(massTxt);
			var massVal:TextField = new TextField();
			massVal.x = vP;
			massVal.y = 212;
			massVal.textColor = 0xffffff;
			addChild(massVal);
			MassSlider = new Slider();
			addChild(MassSlider);
			MassSlider.x  = 47;
			MassSlider.y = 217;
			MassSlider.addEventListener(Event.CHANGE, function(e:Event):void
			{
				massVal.text = (MassSlider.value +1).toString();
				var hero:BaseRobot = RobotFactory.GetHero();
				if (hero != null)
				   hero.SetMass(MassSlider.value);
				else  
				   var t:AlertTrace = new AlertTrace("请先添加主机器人");
			});
			MassSlider.value = 4;
			massTxt.selectable = false;
			massVal.selectable = false;
			massVal.text = (MassSlider.value + 1).toString();
			
			var speedTxt:TextField = new TextField();
			speedTxt.text = "最大速度   × ";
			speedTxt.x = tP;
			speedTxt.y = 242;
			speedTxt.textColor = 0xffffff;
			addChild(speedTxt);
			var speedVal:TextField = new TextField();
			speedVal.x = vP;
			speedVal.y = 242;
			speedVal.textColor = 0xffffff;
			addChild(speedVal);
			SpeedSlider = new Slider();
			addChild(SpeedSlider);
			SpeedSlider.x  = 47;
			SpeedSlider.y = 247;
			SpeedSlider.addEventListener(Event.CHANGE, function(e:Event):void
			{
				speedVal.text = (SpeedSlider.value +1).toString();
			});
			speedTxt.selectable = false;
			speedVal.selectable = false;
			SpeedSlider.value = 4;
			speedVal.text = (SpeedSlider.value +1).toString();
			
			var forceTxt:TextField = new TextField();
			forceTxt.text = "发动机最大输出 × ";
			forceTxt.x = tP;
			forceTxt.y = 272;
			forceTxt.textColor = 0xffffff;
			addChild(forceTxt);
			var forceVal:TextField = new TextField();
			forceVal.x = vP;
			forceVal.y = 272;
			forceVal.textColor = 0xffffff;
			addChild(forceVal);
			ForceSlider = new Slider();
			addChild(ForceSlider);
			ForceSlider.x  = 47;
			ForceSlider.y = 277;
			ForceSlider.addEventListener(Event.CHANGE, function(e:Event):void
			{
				forceVal.text = (ForceSlider.value +1).toString();
			});
			forceTxt.selectable = false;
			forceVal.selectable = false;
			ForceSlider.value = 4;
			forceVal.text = (ForceSlider.value + 1).toString();
		}
	}
}